[libvirt] [PATCH 0/1] Function declarations match definitions
by Chris Venteicher
Interested in fixing mismatches between function parameter names in declarations
(header files) and definitions (.c files)?
This is a cosmetic / redability fix and does not change functionality.
This is patch 1 of larger set of 22 patches that fix parameter names across the
libvirt source code. If there is interest I can send the entire patch set.
These are cosmetic redability fixes automatically generated by clang-tidy.
make check and make syntax-check pass successfully after the 22 patches are
applied.
This is my first submission so please point out any issues and I will be glad to
fix.
Chris Venteicher (1):
includes: function parameter names same in headers
include/libvirt/libvirt-domain.h | 26 +++++++++++++-------------
include/libvirt/libvirt-event.h | 4 ++--
include/libvirt/libvirt-host.h | 4 ++--
include/libvirt/libvirt-interface.h | 4 ++--
include/libvirt/libvirt-network.h | 6 +++---
include/libvirt/libvirt-nwfilter.h | 2 +-
include/libvirt/libvirt-qemu.h | 2 +-
include/libvirt/libvirt-secret.h | 4 ++--
include/libvirt/libvirt-storage.h | 12 ++++++------
include/libvirt/libvirt-stream.h | 22 +++++++++++-----------
10 files changed, 43 insertions(+), 43 deletions(-)
--
2.14.1
6 years, 10 months
[libvirt] [PATCH REBASE 0/2] qemu: Clean up PCI controller options
by Andrea Bolognani
Rebase of
https://www.redhat.com/archives/libvir-list/2017-December/msg00154.html
on top of master, now that patch 1/3 has been merged as part of
John's work to move controller checks from command line generation
to guest validation.
Andrea Bolognani (2):
tests: Add some tests for PCI controller options
qemu: Clean up PCI controller options
src/qemu/qemu_domain.c | 117 +++++++++++++++++++++
.../i440fx-controllers-pciopts.args | 24 +++++
.../i440fx-controllers-pciopts.xml | 36 +++++++
.../pseries-controllers-pciopts.args | 22 ++++
.../pseries-controllers-pciopts.xml | 36 +++++++
.../qemuxml2argvdata/q35-controllers-pciopts.args | 28 +++++
tests/qemuxml2argvdata/q35-controllers-pciopts.xml | 60 +++++++++++
tests/qemuxml2argvtest.c | 17 +++
.../i440fx-controllers-pciopts.xml | 42 ++++++++
tests/qemuxml2xmloutdata/pcie-expander-bus.xml | 4 +-
.../pseries-controllers-pciopts.xml | 41 ++++++++
.../qemuxml2xmloutdata/q35-controllers-pciopts.xml | 63 +++++++++++
tests/qemuxml2xmltest.c | 17 +++
13 files changed, 504 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/i440fx-controllers-pciopts.args
create mode 100644 tests/qemuxml2argvdata/i440fx-controllers-pciopts.xml
create mode 100644 tests/qemuxml2argvdata/pseries-controllers-pciopts.args
create mode 100644 tests/qemuxml2argvdata/pseries-controllers-pciopts.xml
create mode 100644 tests/qemuxml2argvdata/q35-controllers-pciopts.args
create mode 100644 tests/qemuxml2argvdata/q35-controllers-pciopts.xml
create mode 100644 tests/qemuxml2xmloutdata/i440fx-controllers-pciopts.xml
create mode 100644 tests/qemuxml2xmloutdata/pseries-controllers-pciopts.xml
create mode 100644 tests/qemuxml2xmloutdata/q35-controllers-pciopts.xml
--
2.14.3
6 years, 10 months
[libvirt] [PATCH] qemu: Fix indentation in qemuBuildControllerDevStr()
by Andrea Bolognani
Add braces around the multi-line body as well, in compliance
with our coding style.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Pushed as trivial.
src/qemu/qemu_command.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f7925c93a..6c73cd7bf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2743,9 +2743,10 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s",
modelName, pciopts->busNr,
def->info.alias);
- if (pciopts->numaNode != -1)
- virBufferAsprintf(&buf, ",numa_node=%d",
- pciopts->numaNode);
+ if (pciopts->numaNode != -1) {
+ virBufferAsprintf(&buf, ",numa_node=%d",
+ pciopts->numaNode);
+ }
break;
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
--
2.14.3
6 years, 10 months
[libvirt] [PATCH 00/14] Basic implementation of persistent reservations
by Michal Privoznik
QEMU added support for SCSI persistent reservations. The way QEMU
implemented that makes it slightly harder for libvirt to adapt to - it's
a small binary that needs to start before qemu so that it can connect to
it. Basically, what libvirt does is:
1) start qemu-pr-helper (the small binary from above),
2) records its PID for tracking purposes
3) start qemu
and when shutting down a domain the process is reversed:
1) shut down qemu process,
2) kill qemu-pr-helper (PID was saved earlier).
Now, here also lies the last missing piece to he puzzle - what if
qemu-pr-helper dies while qemu is running? After some discussion with
Paolo it was agreed that qemu will emit an event for libvirt so that we
can respawn the process. Anyway, that shouldn't be a show stopper for
these patches (if it was the patch set might get too big).
Please test, review and comment.
As usual, you can find the patches on my github too:
https://github.com/zippy2/libvirt/tree/pr
Michal Privoznik (14):
virstoragefile: Introduce virStoragePRDef
qemuDomainDiskChangeSupported: Deny changing reservations
qemu: Introduce pr-manager-helper capability
qemu_domain: Introduce qemuDomainDiskPRObject
qemu: Generate alias for pr-helper
qemu: Store prAlias and prPath in status XML
qemu: Generate cmd line at startup
qemu: Introduce pr_helper to qemu.conf
qemu: Start PR daemons on domain startup
qemu: Track PR daemons PIDs in status XML
qemu_domain: Introduce qemuDomainGetPRUsageCount
qemu_process.c: Introduce qemuProcessSetupPRDaemon
qemu_hotplug: Hotplug of reservations
qemu_hotplug: Hotunplug of reservations
docs/formatdomain.html.in | 25 +-
docs/schemas/domaincommon.rng | 19 +-
docs/schemas/storagecommon.rng | 34 ++
m4/virt-driver-qemu.m4 | 5 +
src/conf/domain_conf.c | 36 ++
src/libvirt_private.syms | 4 +
src/qemu/libvirtd_qemu.aug | 1 +
src/qemu/qemu.conf | 4 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 59 +++
src/qemu/qemu_conf.c | 7 +-
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_domain.c | 435 ++++++++++++++++++++-
src/qemu/qemu_domain.h | 29 ++
src/qemu/qemu_hotplug.c | 110 ++++++
src/qemu/qemu_process.c | 160 ++++++++
src/qemu/qemu_process.h | 4 +
src/qemu/test_libvirtd_qemu.aug.in | 1 +
src/util/virstoragefile.c | 166 ++++++++
src/util/virstoragefile.h | 17 +
.../disk-virtio-scsi-reservations-not-managed.args | 28 ++
.../disk-virtio-scsi-reservations-not-managed.xml | 40 ++
.../disk-virtio-scsi-reservations.args | 29 ++
.../disk-virtio-scsi-reservations.xml | 38 ++
tests/qemuxml2argvtest.c | 8 +
.../disk-virtio-scsi-reservations-not-managed.xml | 1 +
.../disk-virtio-scsi-reservations.xml | 1 +
tests/qemuxml2xmltest.c | 4 +
29 files changed, 1250 insertions(+), 19 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.args
create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.xml
create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations.args
create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations.xml
create mode 120000 tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations-not-managed.xml
create mode 120000 tests/qemuxml2xmloutdata/disk-virtio-scsi-reservations.xml
--
2.13.6
6 years, 10 months
[libvirt] [PATCH] Revert "qemu: Expose rx/tx_queue_size in qemu.conf too"
by Daniel P. Berrangé
This reverts commit 038eb472a0d970a17ccf4343ead0666df5c92f9d.
On reflection adding defaults for arbitrary guest XML device config
settings to the qemu.conf is not a sustainable path. Removing the
support for rx/tx queue size so that it doesn't set a bad precedent.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
docs/formatdomain.html.in | 14 ++--------
src/qemu/libvirtd_qemu.aug | 4 ---
src/qemu/qemu.conf | 6 -----
src/qemu/qemu_command.c | 55 +++++++++++---------------------------
src/qemu/qemu_command.h | 3 +--
src/qemu/qemu_conf.c | 4 ---
src/qemu/qemu_conf.h | 3 ---
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/test_libvirtd_qemu.aug.in | 2 --
9 files changed, 19 insertions(+), 74 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6707744bda..3ec1173c6f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5456,12 +5456,7 @@ qemu-kvm -net nic,model=? /dev/null
some restrictions on actual value. For instance, latest
QEMU (as of 2016-09-01) requires value to be a power of two
from [256, 1024] range.
- <span class="since">Since 2.3.0 (QEMU and KVM only)</span>
- Additionally, <span class="since">since 4.1.0</span> the
- value can be set in the <code>qemu.conf</code> file in order
- to override the hypervisor default value. Note that XML has
- higher precedence because it's more specific.
- <br/><br/>
+ <span class="since">Since 2.3.0 (QEMU and KVM only)</span><br/><br/>
<b>In general you should leave this option alone, unless you
are very certain you know what you are doing.</b>
@@ -5477,12 +5472,7 @@ qemu-kvm -net nic,model=? /dev/null
range. In addition to that, this may work only for a subset of
interface types, e.g. aforementioned QEMU enables this option
only for <code>vhostuser</code> type.
- <span class="since">Since 3.7.0 (QEMU and KVM only)</span>
- Additionally, <span class="since">since 4.1.0</span> the
- value can be set in the <code>qemu.conf</code> file in order
- to override the hypervisor default value. Note that XML has
- higher precedence because it's more specific.
- <br/><br/>
+ <span class="since">Since 3.7.0 (QEMU and KVM only)</span><br/><br/>
<b>In general you should leave this option alone, unless you
are very certain you know what you are doing.</b>
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 084290296a..c19bf3a43a 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -118,9 +118,6 @@ module Libvirtd_qemu =
let vxhs_entry = bool_entry "vxhs_tls"
| str_entry "vxhs_tls_x509_cert_dir"
- let virtio_entry = int_entry "rx_queue_size"
- | int_entry "tx_queue_size"
-
(* Each entry in the config is one of the following ... *)
let entry = default_tls_entry
| vnc_entry
@@ -140,7 +137,6 @@ module Libvirtd_qemu =
| gluster_debug_level_entry
| memory_entry
| vxhs_entry
- | virtio_entry
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
let empty = [ label "#empty" . eol ]
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 62c4265ea9..43dd561cca 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -775,9 +775,3 @@
# This directory is used for memoryBacking source if configured as file.
# NOTE: big files will be stored here
#memory_backing_dir = "/var/lib/libvirt/qemu/ram"
-
-# The following two values set the default RX/TX ring buffer size for virtio
-# interfaces. These values are taken unless overridden in domain XML. For more
-# info consult docs to corresponding attributes from domain XML.
-#rx_queue_size = 1024
-#tx_queue_size = 1024
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2bcaa5fc22..f7925c93a8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3351,8 +3351,7 @@ qemuBuildNicStr(virDomainNetDefPtr net,
char *
-qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg,
- virDomainDefPtr def,
+qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
unsigned int bootindex,
@@ -3472,41 +3471,21 @@ qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg,
virBufferAsprintf(&buf, ",mq=on,vectors=%zu", 2 * vhostfdSize + 2);
}
}
- if (usingVirtio) {
- unsigned int rx_queue_size = net->driver.virtio.rx_queue_size;
-
- if (rx_queue_size == 0)
- rx_queue_size = cfg->rx_queue_size;
-
- if (rx_queue_size) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtio rx_queue_size option is "
- "not supported with this QEMU binary"));
- goto error;
- }
-
- net->driver.virtio.rx_queue_size = rx_queue_size;
- virBufferAsprintf(&buf, ",rx_queue_size=%u", rx_queue_size);
+ if (usingVirtio && net->driver.virtio.rx_queue_size) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio rx_queue_size option is not supported with this QEMU binary"));
+ goto error;
}
+ virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
}
- if (usingVirtio) {
- unsigned int tx_queue_size = net->driver.virtio.tx_queue_size;
-
- if (tx_queue_size == 0)
- tx_queue_size = cfg->tx_queue_size;
-
- if (tx_queue_size) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtio tx_queue_size option is "
- "not supported with this QEMU binary"));
- goto error;
- }
-
- net->driver.virtio.tx_queue_size = tx_queue_size;
- virBufferAsprintf(&buf, ",tx_queue_size=%u", tx_queue_size);
+ if (usingVirtio && net->driver.virtio.tx_queue_size) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio tx_queue_size option is not supported with this QEMU binary"));
+ goto error;
}
+ virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_queue_size);
}
if (usingVirtio && net->mtu) {
@@ -8192,7 +8171,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
virCommandAddArg(cmd, netdev);
VIR_FREE(netdev);
- if (!(nic = qemuBuildNicDevStr(cfg, def, net, -1, bootindex,
+ if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
queues, qemuCaps))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error generating NIC -device string"));
@@ -8229,7 +8208,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
int **nicindexes,
bool chardevStdioLogd)
{
- virQEMUDriverConfigPtr cfg = NULL;
int ret = -1;
char *nic = NULL, *host = NULL;
int *tapfd = NULL;
@@ -8291,8 +8269,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
return -1;
}
- cfg = virQEMUDriverGetConfig(driver);
-
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
@@ -8488,7 +8464,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
virCommandAddArgList(cmd, "-netdev", host, NULL);
}
if (qemuDomainSupportsNicdev(def, net)) {
- if (!(nic = qemuBuildNicDevStr(cfg, def, net, vlan, bootindex,
+ if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
vhostfdSize, qemuCaps)))
goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL);
@@ -8532,7 +8508,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
VIR_FREE(host);
VIR_FREE(tapfdName);
VIR_FREE(vhostfdName);
- virObjectUnref(cfg);
return ret;
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 6449883291..31c9da673c 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -90,8 +90,7 @@ char *qemuBuildNicStr(virDomainNetDefPtr net,
int vlan);
/* Current, best practice */
-char *qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg,
- virDomainDefPtr def,
+char *qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
unsigned int bootindex,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2fa96431fa..af503d31cb 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -912,10 +912,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
if (virConfGetValueString(conf, "memory_backing_dir", &cfg->memoryBackingDir) < 0)
goto cleanup;
- if (virConfGetValueUInt(conf, "rx_queue_size", &cfg->rx_queue_size) < 0 ||
- virConfGetValueUInt(conf, "tx_queue_size", &cfg->tx_queue_size) < 0)
- goto cleanup;
-
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 3f38a76c26..a553e30e2e 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -206,9 +206,6 @@ struct _virQEMUDriverConfig {
bool vxhsTLS;
char *vxhsTLSx509certdir;
-
- unsigned int rx_queue_size;
- unsigned int tx_queue_size;
};
/* Main driver state */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3291ce6130..c9868de778 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1118,7 +1118,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
for (i = 0; i < vhostfdSize; i++)
VIR_FORCE_CLOSE(vhostfd[i]);
- if (!(nicstr = qemuBuildNicDevStr(cfg, vm->def, net, vlan, 0,
+ if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
queueSize, priv->qemuCaps)))
goto try_remove;
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 4fc4e2f4ec..688e5b9fda 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -100,5 +100,3 @@ module Test_libvirtd_qemu =
{ "1" = "mount" }
}
{ "memory_backing_dir" = "/var/lib/libvirt/qemu/ram" }
-{ "rx_queue_size" = "1024" }
-{ "tx_queue_size" = "1024" }
--
2.14.3
6 years, 10 months
[libvirt] [PATCH v2] vcpupin: add clear feature
by Yi Wang
We can't clear vcpupin settings of XML once we did vcpupin
command, this is not convenient under some condition such
as migration to a host with less CPUs.
This patch introduces clear feature, which can clear vcpuin
setting of XML using a 'c' option.
Signed-off-by: Yi Wang <wang.yi59(a)zte.com.cn>
Signed-off-by: Xi Xu <xu.xi8(a)zte.com.cn>
---
include/libvirt/libvirt-domain.h | 11 +++++++++++
src/qemu/qemu_driver.c | 32 ++++++++++++++++++++++++--------
tools/virsh-domain.c | 5 ++++-
tools/virsh.pod | 1 +
4 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4048acf..46f4e77 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1847,6 +1847,17 @@ int virDomainSetVcpusFlags (virDomainPtr domain,
int virDomainGetVcpusFlags (virDomainPtr domain,
unsigned int flags);
+/* Flags for controlling virtual CPU pinning. */
+typedef enum {
+ /* See virDomainModificationImpact for these flags. */
+ VIR_DOMAIN_VCPU_PIN_CURRENT = VIR_DOMAIN_AFFECT_CURRENT,
+ VIR_DOMAIN_VCPU_PIN_LIVE = VIR_DOMAIN_AFFECT_LIVE,
+ VIR_DOMAIN_VCPU_PIN_CONFIG = VIR_DOMAIN_AFFECT_CONFIG,
+
+ /* Additionally, these flags may be bitwise-OR'd in. */
+ VIR_DOMAIN_VCPU_PIN_CLEAR = (1 << 2), /* Clear vcpus pin info */
+} virDomainVcpuPinFlags;
+
int virDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bbce5bd..fe1f62f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5056,7 +5056,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
int vcpu,
virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg,
- virBitmapPtr cpumap)
+ virBitmapPtr cpumap,
+ bool clear)
{
virBitmapPtr tmpmap = NULL;
virDomainVcpuDefPtr vcpuinfo;
@@ -5069,6 +5070,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
int eventNparams = 0;
int eventMaxparams = 0;
int ret = -1;
+ virBitmapPtr targetMap = NULL;
if (!qemuDomainHasVcpuPids(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
@@ -5083,10 +5085,15 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
goto cleanup;
}
- if (!(tmpmap = virBitmapNewCopy(cpumap)))
- goto cleanup;
+ if (clear) {
+ targetMap = virHostCPUGetOnlineBitmap();
+ } else {
+ targetMap = cpumap;
+ if (!(tmpmap = virBitmapNewCopy(cpumap)))
+ goto cleanup;
+ }
- if (!(str = virBitmapFormat(cpumap)))
+ if (!(str = virBitmapFormat(targetMap)))
goto cleanup;
if (vcpuinfo->online) {
@@ -5095,11 +5102,11 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu,
false, &cgroup_vcpu) < 0)
goto cleanup;
- if (qemuSetupCgroupCpusetCpus(cgroup_vcpu, cpumap) < 0)
+ if (qemuSetupCgroupCpusetCpus(cgroup_vcpu, targetMap) < 0)
goto cleanup;
}
- if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), cpumap) < 0)
+ if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), targetMap) < 0)
goto cleanup;
}
@@ -5128,6 +5135,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
virCgroupFree(&cgroup_vcpu);
VIR_FREE(str);
qemuDomainEventQueue(driver, event);
+ if (clear)
+ virBitmapFree(targetMap);
return ret;
}
@@ -5148,9 +5157,11 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
virBitmapPtr pcpumap = NULL;
virDomainVcpuDefPtr vcpuinfo = NULL;
virQEMUDriverConfigPtr cfg = NULL;
+ bool clear = false;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
- VIR_DOMAIN_AFFECT_CONFIG, -1);
+ VIR_DOMAIN_AFFECT_CONFIG |
+ VIR_DOMAIN_VCPU_PIN_CLEAR, -1);
cfg = virQEMUDriverGetConfig(driver);
@@ -5166,6 +5177,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
goto endjob;
+ clear = !!(flags & VIR_DOMAIN_VCPU_PIN_CLEAR);
+
if ((def && def->virtType == VIR_DOMAIN_VIRT_QEMU) ||
(persistentDef && persistentDef->virtType == VIR_DOMAIN_VIRT_QEMU)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -5191,7 +5204,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
}
if (def &&
- qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap) < 0)
+ qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap, clear) < 0)
goto endjob;
if (persistentDef) {
@@ -5199,6 +5212,9 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
vcpuinfo->cpumask = pcpumap;
pcpumap = NULL;
+ if (clear)
+ virBitmapFree(vcpuinfo->cpumask);
+
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 5a0e0c1..4981ecc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6863,7 +6863,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen,
unsigned char *cpumap = NULL;
virBitmapPtr map = NULL;
- if (cpulist[0] == 'r') {
+ if (cpulist[0] == 'r' || cpulist[0] == 'c') {
if (!(map = virBitmapNew(maxcpu)))
return NULL;
virBitmapSetAll(map);
@@ -6941,6 +6941,9 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
+ if (STREQ(cpulist, "c"))
+ flags |= VIR_DOMAIN_VCPU_PIN_CLEAR;
+
/* Pin mode: pinning specified vcpu to specified physical cpus*/
if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 69cc423..d5a1779 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2857,6 +2857,7 @@ I<cpulist> is a list of physical CPU numbers. Its syntax is a comma
separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can
also be allowed. The '-' denotes the range and the '^' denotes exclusive.
For pinning the I<vcpu> to all physical cpus specify 'r' as a I<cpulist>.
+For clearing pinning info, specify 'c' as a I<cpulist>.
If I<--live> is specified, affect a running guest.
If I<--config> is specified, affect the next boot of a persistent guest.
If I<--current> is specified, affect the current guest state.
--
1.8.3.1
6 years, 10 months
[libvirt] [PATCH] log: fix deadlock obtaining hostname (related CVE-2018-6764)
by Daniel P. Berrangé
The fix for CVE-2018-6764 introduced a potential deadlock scenario
that gets triggered by the NSS module when virGetHostname() calls
getaddrinfo to resolve the hostname:
#0 0x00007f6e714b57e7 in futex_wait
#1 futex_wait_simple
#2 __pthread_once_slow
#3 0x00007f6e71d16e7d in virOnce
#4 0x00007f6e71d0997c in virLogInitialize
#5 0x00007f6e71d0a09a in virLogVMessage
#6 0x00007f6e71d09ffd in virLogMessage
#7 0x00007f6e71d0db22 in virObjectNew
#8 0x00007f6e71d0dbf1 in virObjectLockableNew
#9 0x00007f6e71d0d3e5 in virMacMapNew
#10 0x00007f6e71cdc50a in findLease
#11 0x00007f6e71cdcc56 in _nss_libvirt_gethostbyname4_r
#12 0x00007f6e724631fc in gaih_inet
#13 0x00007f6e72464697 in __GI_getaddrinfo
#14 0x00007f6e71d19e81 in virGetHostnameImpl
#15 0x00007f6e71d1a057 in virGetHostnameQuiet
#16 0x00007f6e71d09936 in virLogOnceInit
#17 0x00007f6e71d09952 in virLogOnce
#18 0x00007f6e714b5829 in __pthread_once_slow
#19 0x00007f6e71d16e7d in virOnce
#20 0x00007f6e71d0997c in virLogInitialize
#21 0x00007f6e71d0a09a in virLogVMessage
#22 0x00007f6e71d09ffd in virLogMessage
#23 0x00007f6e71d0db22 in virObjectNew
#24 0x00007f6e71d0dbf1 in virObjectLockableNew
#25 0x00007f6e71d0d3e5 in virMacMapNew
#26 0x00007f6e71cdc50a in findLease
#27 0x00007f6e71cdc839 in _nss_libvirt_gethostbyname3_r
#28 0x00007f6e71cdc724 in _nss_libvirt_gethostbyname2_r
#29 0x00007f6e7248f72f in __gethostbyname2_r
#30 0x00007f6e7248f494 in gethostbyname2
#31 0x000056348c30c36d in hosts_keys
#32 0x000056348c30b7d2 in main
Fortunately the extra stuff virGetHostname does is totally irrelevant to
the needs of the logging code, so we can just inline a call to the
native hostname() syscall directly.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/util/virlog.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 8f1e4800dd..4f66cc5e5c 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -64,7 +64,7 @@
VIR_LOG_INIT("util.log");
static regex_t *virLogRegex;
-static char *virLogHostname;
+static char virLogHostname[HOST_NAME_MAX+1];
#define VIR_LOG_DATE_REGEX "[0-9]{4}-[0-9]{2}-[0-9]{2}"
@@ -261,6 +261,8 @@ virLogPriorityString(virLogPriority lvl)
static int
virLogOnceInit(void)
{
+ int r;
+
if (virMutexInit(&virLogMutex) < 0)
return -1;
@@ -275,8 +277,17 @@ virLogOnceInit(void)
/* We get and remember the hostname early, because at later time
* it might not be possible to load NSS modules via getaddrinfo()
* (e.g. at container startup the host filesystem will not be
- * accessible anymore. */
- virLogHostname = virGetHostnameQuiet();
+ * accessible anymore.
+ * Must not use virGetHostname though as that causes re-entrancy
+ * problems if it triggers logging codepaths
+ */
+ r = gethostname(virLogHostname, sizeof(virLogHostname));
+ if (r == -1) {
+ ignore_value(virStrcpy(virLogHostname,
+ "(unknown)", sizeof(virLogHostname)));
+ } else {
+ NUL_TERMINATE(virLogHostname);
+ }
virLogUnlock();
return 0;
@@ -475,9 +486,6 @@ virLogHostnameString(char **rawmsg,
{
char *hoststr;
- if (!virLogHostname)
- return -1;
-
if (virAsprintfQuiet(&hoststr, "hostname: %s", virLogHostname) < 0)
return -1;
--
2.14.3
6 years, 10 months
[libvirt] [PATCH v2] qemu: Expose rx/tx_queue_size in qemu.conf too
by Michal Privoznik
In 2074ef6cd4a2 and c56cdf259 (and friends) we've added two
attributes to virtio NICs: rx_queue_size and tx_queue_size.
However, sysadmins might want to set these on per-host basis but
don't necessarily have an access to domain XML (e.g. because they
are generated by some other app). So let's expose them under
qemu.conf (the settings from domain XML still take precedence as
they are more specific ones).
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
diff to v1:
- Reworded docs and config file comment
- Simplified logic in qemuBuildNicDevStr a bit
- Make the values require qemu with corresponding capabilities
docs/formatdomain.html.in | 14 ++++++++--
src/qemu/libvirtd_qemu.aug | 4 +++
src/qemu/qemu.conf | 6 +++++
src/qemu/qemu_command.c | 55 +++++++++++++++++++++++++++-----------
src/qemu/qemu_command.h | 3 ++-
src/qemu/qemu_conf.c | 4 +++
src/qemu/qemu_conf.h | 3 +++
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/test_libvirtd_qemu.aug.in | 2 ++
9 files changed, 74 insertions(+), 19 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3ec1173c6..6707744bd 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5456,7 +5456,12 @@ qemu-kvm -net nic,model=? /dev/null
some restrictions on actual value. For instance, latest
QEMU (as of 2016-09-01) requires value to be a power of two
from [256, 1024] range.
- <span class="since">Since 2.3.0 (QEMU and KVM only)</span><br/><br/>
+ <span class="since">Since 2.3.0 (QEMU and KVM only)</span>
+ Additionally, <span class="since">since 4.1.0</span> the
+ value can be set in the <code>qemu.conf</code> file in order
+ to override the hypervisor default value. Note that XML has
+ higher precedence because it's more specific.
+ <br/><br/>
<b>In general you should leave this option alone, unless you
are very certain you know what you are doing.</b>
@@ -5472,7 +5477,12 @@ qemu-kvm -net nic,model=? /dev/null
range. In addition to that, this may work only for a subset of
interface types, e.g. aforementioned QEMU enables this option
only for <code>vhostuser</code> type.
- <span class="since">Since 3.7.0 (QEMU and KVM only)</span><br/><br/>
+ <span class="since">Since 3.7.0 (QEMU and KVM only)</span>
+ Additionally, <span class="since">since 4.1.0</span> the
+ value can be set in the <code>qemu.conf</code> file in order
+ to override the hypervisor default value. Note that XML has
+ higher precedence because it's more specific.
+ <br/><br/>
<b>In general you should leave this option alone, unless you
are very certain you know what you are doing.</b>
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index c19bf3a43..084290296 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -118,6 +118,9 @@ module Libvirtd_qemu =
let vxhs_entry = bool_entry "vxhs_tls"
| str_entry "vxhs_tls_x509_cert_dir"
+ let virtio_entry = int_entry "rx_queue_size"
+ | int_entry "tx_queue_size"
+
(* Each entry in the config is one of the following ... *)
let entry = default_tls_entry
| vnc_entry
@@ -137,6 +140,7 @@ module Libvirtd_qemu =
| gluster_debug_level_entry
| memory_entry
| vxhs_entry
+ | virtio_entry
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
let empty = [ label "#empty" . eol ]
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 43dd561cc..62c4265ea 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -775,3 +775,9 @@
# This directory is used for memoryBacking source if configured as file.
# NOTE: big files will be stored here
#memory_backing_dir = "/var/lib/libvirt/qemu/ram"
+
+# The following two values set the default RX/TX ring buffer size for virtio
+# interfaces. These values are taken unless overridden in domain XML. For more
+# info consult docs to corresponding attributes from domain XML.
+#rx_queue_size = 1024
+#tx_queue_size = 1024
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 899f0cbbb..543270028 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3751,7 +3751,8 @@ qemuBuildNicStr(virDomainNetDefPtr net,
char *
-qemuBuildNicDevStr(virDomainDefPtr def,
+qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg,
+ virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
unsigned int bootindex,
@@ -3871,21 +3872,41 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virBufferAsprintf(&buf, ",mq=on,vectors=%zu", 2 * vhostfdSize + 2);
}
}
- if (usingVirtio && net->driver.virtio.rx_queue_size) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtio rx_queue_size option is not supported with this QEMU binary"));
- goto error;
+ if (usingVirtio) {
+ unsigned int rx_queue_size = net->driver.virtio.rx_queue_size;
+
+ if (rx_queue_size == 0)
+ rx_queue_size = cfg->rx_queue_size;
+
+ if (rx_queue_size) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio rx_queue_size option is "
+ "not supported with this QEMU binary"));
+ goto error;
+ }
+
+ net->driver.virtio.rx_queue_size = rx_queue_size;
+ virBufferAsprintf(&buf, ",rx_queue_size=%u", rx_queue_size);
}
- virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
}
- if (usingVirtio && net->driver.virtio.tx_queue_size) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtio tx_queue_size option is not supported with this QEMU binary"));
- goto error;
+ if (usingVirtio) {
+ unsigned int tx_queue_size = net->driver.virtio.tx_queue_size;
+
+ if (tx_queue_size == 0)
+ tx_queue_size = cfg->tx_queue_size;
+
+ if (tx_queue_size) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio tx_queue_size option is "
+ "not supported with this QEMU binary"));
+ goto error;
+ }
+
+ net->driver.virtio.tx_queue_size = tx_queue_size;
+ virBufferAsprintf(&buf, ",tx_queue_size=%u", tx_queue_size);
}
- virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_queue_size);
}
if (usingVirtio && net->mtu) {
@@ -8571,7 +8592,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
virCommandAddArg(cmd, netdev);
VIR_FREE(netdev);
- if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
+ if (!(nic = qemuBuildNicDevStr(cfg, def, net, -1, bootindex,
queues, qemuCaps))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error generating NIC -device string"));
@@ -8608,6 +8629,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
int **nicindexes,
bool chardevStdioLogd)
{
+ virQEMUDriverConfigPtr cfg = NULL;
int ret = -1;
char *nic = NULL, *host = NULL;
int *tapfd = NULL;
@@ -8669,6 +8691,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
return -1;
}
+ cfg = virQEMUDriverGetConfig(driver);
+
switch (actualType) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
@@ -8864,7 +8888,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
virCommandAddArgList(cmd, "-netdev", host, NULL);
}
if (qemuDomainSupportsNicdev(def, net)) {
- if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
+ if (!(nic = qemuBuildNicDevStr(cfg, def, net, vlan, bootindex,
vhostfdSize, qemuCaps)))
goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL);
@@ -8908,6 +8932,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
VIR_FREE(host);
VIR_FREE(tapfdName);
VIR_FREE(vhostfdName);
+ virObjectUnref(cfg);
return ret;
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 31c9da673..644988329 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -90,7 +90,8 @@ char *qemuBuildNicStr(virDomainNetDefPtr net,
int vlan);
/* Current, best practice */
-char *qemuBuildNicDevStr(virDomainDefPtr def,
+char *qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg,
+ virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
unsigned int bootindex,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index af503d31c..2fa96431f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -912,6 +912,10 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
if (virConfGetValueString(conf, "memory_backing_dir", &cfg->memoryBackingDir) < 0)
goto cleanup;
+ if (virConfGetValueUInt(conf, "rx_queue_size", &cfg->rx_queue_size) < 0 ||
+ virConfGetValueUInt(conf, "tx_queue_size", &cfg->tx_queue_size) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index a553e30e2..3f38a76c2 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -206,6 +206,9 @@ struct _virQEMUDriverConfig {
bool vxhsTLS;
char *vxhsTLSx509certdir;
+
+ unsigned int rx_queue_size;
+ unsigned int tx_queue_size;
};
/* Main driver state */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 2aa927e62..0672ed130 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1120,7 +1120,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
for (i = 0; i < vhostfdSize; i++)
VIR_FORCE_CLOSE(vhostfd[i]);
- if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
+ if (!(nicstr = qemuBuildNicDevStr(cfg, vm->def, net, vlan, 0,
queueSize, priv->qemuCaps)))
goto try_remove;
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 688e5b9fd..4fc4e2f4e 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -100,3 +100,5 @@ module Test_libvirtd_qemu =
{ "1" = "mount" }
}
{ "memory_backing_dir" = "/var/lib/libvirt/qemu/ram" }
+{ "rx_queue_size" = "1024" }
+{ "tx_queue_size" = "1024" }
--
2.13.6
6 years, 10 months
[libvirt] [PATCH] tests: fix running of qemuxml2argvtest program
by Daniel P. Berrangé
The previous commit:
commit a455d41e3e1c1af3a36ccdbb2e3f2356cc58993e
Author: Daniel P. Berrangé <berrange(a)redhat.com>
Date: Thu Jan 25 09:35:50 2018 +0000
conf: expand network device callbacks to cover resolving NIC type
mistakenly dropped qemuxml2argvtest from the tests due to a typo.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
tests/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d013aed5eb..4ff3fa742a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -291,7 +291,7 @@ test_programs += qemuxml2xmltest \
if WITH_NETWORK
# Dep on the network driver callback for resolving NIC
# actual type. XXX remove this dep.
-test_programs += qemuxml2xmltest
+test_programs += qemuxml2argvtest
endif WITH_NETWORK
test_helpers += qemucapsprobe
test_libraries += libqemumonitortestutils.la \
--
2.14.3
6 years, 10 months