[libvirt] [PATCH 0/4] Xen: Improve support for <timer> configurations
by Jim Fehlig
This series fixes some issues wrt <timer> configuration in the libxl
driver and the xenconfig parser/formatter. See patches 1 and 2 for
details on the libxl driver changes, and patch 3 for details on the
xenconfig parser/formatter changes. Patch 4 adds some tests to check
domXML <-> xl.cfg conversions of <timer> configuration.
Jim Fehlig (4):
libxl: fix timer configuration
libxl: support emulate mode of tsc timer
xenconfig: add support for more timers
tests: add xlconfig tests for <timer> configurations
src/libxl/libxl_conf.c | 49 +++++++++----
src/xenconfig/xen_common.c | 87 +++++++++++++++++++++---
tests/xlconfigdata/test-fullvirt-hpet-timer.cfg | 27 ++++++++
tests/xlconfigdata/test-fullvirt-hpet-timer.xml | 64 +++++++++++++++++
tests/xlconfigdata/test-fullvirt-multi-timer.cfg | 28 ++++++++
tests/xlconfigdata/test-fullvirt-multi-timer.xml | 65 ++++++++++++++++++
tests/xlconfigdata/test-fullvirt-tsc-timer.cfg | 27 ++++++++
tests/xlconfigdata/test-fullvirt-tsc-timer.xml | 64 +++++++++++++++++
tests/xlconfigtest.c | 3 +
9 files changed, 392 insertions(+), 22 deletions(-)
create mode 100644 tests/xlconfigdata/test-fullvirt-hpet-timer.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-hpet-timer.xml
create mode 100644 tests/xlconfigdata/test-fullvirt-multi-timer.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-multi-timer.xml
create mode 100644 tests/xlconfigdata/test-fullvirt-tsc-timer.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-tsc-timer.xml
--
2.9.2
7 years, 11 months
[libvirt] [PATCH 0/3] support setting MTU of libvirt networks
by Laine Stump
This has been requested several times in #virt on IRC, and on
libvirt-users, and a comment posted to
https://bugzilla.redhat.com/1224348 reminded me that there's even an
open BZ for it, so I finally sat down and wrote the patches for it.
The idea of the patches is that an *empty* bridge device can't have
its MTU directly set to anything higher than 1500, but once there are
any devices on the bridge, its MTU is limited to the smallest of the
MTUs of any attached devices. However, when the very first device is
attached to the bridge, the bridge will *increase* its own MTU to
match if needed. So the trick to setting a high MTU is to set the MTU
of every device to the desired value before it is added (especially
the first). libvirt already sets the MTU of every device to the MTU of
the bridge, so all we need to do is make it so the first device is set
from the network config's "mtu" attribute instead - the bridge will
get the larger MTU, and all future devices added will get the higher
MTU as well.
This doesn't take care of setting the MTU on the guest side of the tap
device; for now that must be done manually, but qemu has recently
added a commandline parameter to send the desired MTU to the guest,
and the virtio-net guest driver at least honors this. An upcoming
patch to libvirt will automatically set this qemu commandline option
so that no intervention will be required (beyond setting the MTU once
in the network config).
Laine Stump (3):
util: add MTU arg to virNetDevTapCreateInBridgePort()
conf: support mtu attribute in a network's <bridge> element
network: honor mtu setting when creating network
docs/formatnetwork.html.in | 8 +++++++-
docs/news.xml | 6 +++++-
docs/schemas/network.rng | 6 ++++++
src/bhyve/bhyve_command.c | 2 +-
src/conf/network_conf.c | 20 ++++++++++++++++++--
src/conf/network_conf.h | 1 +
src/network/bridge_driver.c | 1 +
src/qemu/qemu_interface.c | 2 +-
src/uml/uml_conf.c | 2 +-
src/util/virnetdevtap.c | 20 +++++++++++++++-----
src/util/virnetdevtap.h | 1 +
tests/bhyvexml2argvmock.c | 1 +
tests/networkxml2xmlin/set-mtu.xml | 11 +++++++++++
tests/networkxml2xmlout/set-mtu.xml | 11 +++++++++++
tests/networkxml2xmltest.c | 1 +
15 files changed, 81 insertions(+), 12 deletions(-)
create mode 100644 tests/networkxml2xmlin/set-mtu.xml
create mode 100644 tests/networkxml2xmlout/set-mtu.xml
--
2.9.3
7 years, 11 months
[libvirt] [PATCH v2 1/2] util: virhostdev: disallow assigning a pci-bridge to a guest
by Shivaprasad G Bhat
Non-endpoint devices like pci-bridges cannot be passedthrough to guests.
Prevent such attempts.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/util/virhostdev.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 0673afb..b23fe1f 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -532,6 +532,16 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
bool strict_acs_check = !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK);
bool usesVFIO = (virPCIDeviceGetStubDriver(pci) == VIR_PCI_STUB_DRIVER_VFIO);
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, dom_name, usesVFIO };
+ int hdrType = -1;
+
+ if (virPCIGetHeaderType(pci, &hdrType) < 0)
+ goto cleanup;
+
+ if (hdrType != VIR_PCI_HEADER_ENDPOINT) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI bridge devices "
+ "cannot be assigned to guests"));
+ goto cleanup;
+ }
if (!usesVFIO && !virPCIDeviceIsAssignable(pci, strict_acs_check)) {
virReportError(VIR_ERR_OPERATION_INVALID,
7 years, 11 months
[libvirt] [PATCH v2] util: disallow assigning or resetting a pci-bridge device
by Shivaprasad G Bhat
It is destructive to attempt reset on a pci-bridge, the host can crash.
The bridges won't contain any guest data and neither they can be
passed through using vfio/stub. So, no point in allowing a reset on them.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/util/virhostdev.c | 10 ++++++++++
src/util/virpci.c | 11 +++++++++++
2 files changed, 21 insertions(+)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 0673afb..16b96f3 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -532,6 +532,16 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
bool strict_acs_check = !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK);
bool usesVFIO = (virPCIDeviceGetStubDriver(pci) == VIR_PCI_STUB_DRIVER_VFIO);
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, dom_name, usesVFIO };
+ int hdrType = -1;
+
+ if (virPCIGetHeaderType(pci, &hdrType) < 0)
+ goto cleanup;
+
+ if (hdrType == VIR_PCI_HEADER_PCI_BRIDGE) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI bridge devices"
+ " cannot be assigned to guests"));
+ goto cleanup;
+ }
if (!usesVFIO && !virPCIDeviceIsAssignable(pci, strict_acs_check)) {
virReportError(VIR_ERR_OPERATION_INVALID,
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 0601f49..f205abf 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -933,6 +933,17 @@ virPCIDeviceReset(virPCIDevicePtr dev,
char *drvName = NULL;
int ret = -1;
int fd = -1;
+ int hdrType = -1;
+
+ if (virPCIGetHeaderType(dev, &hdrType) < 0)
+ return -1;
+
+ if (hdrType != VIR_PCI_HEADER_ENDPOINT) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid attempt to reset non-endpoint PCI device %s."
+ " Only PCI endpoint devices can be reset"), dev->name);
+ return -1;
+ }
if (activeDevs && virPCIDeviceListFind(activeDevs, dev)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
7 years, 11 months
[libvirt] [PATCH resend v2 0/2] Allow saving QEMU libvirt state to a pipe
by Chen Hanxiao
This series introduce flag VIR_DOMAIN_SAVE_DIRECT
to enable command 'save' to write to PIPE.
Base upon patches from Roy Keene <rkeene(a)knightpoint.com>
with some fixes.
Change from original patch:
1) Check whether the specified path is a PIPE.
2) Rebase on upstream.
3) Add doc for virsh command
v2-resend:
rebase on upstream
v2:
rename VIR_DOMAIN_SAVE_PIPE to VIR_DOMAIN_SAVE_DIRECT
remove S_ISFIFO check
Chen Hanxiao (2):
qemu: Allow saving QEMU libvirt state to a pipe
virsh: introduce flage --direct for save command
include/libvirt/libvirt-domain.h | 1 +
src/qemu/qemu_driver.c | 54 ++++++++++++++++++++++++++--------------
tools/virsh-domain.c | 6 +++++
tools/virsh.pod | 5 +++-
4 files changed, 47 insertions(+), 19 deletions(-)
--
2.7.4
7 years, 11 months
[libvirt] [PATCH v2] qemu_domain: add timestamp in tainting of guests log
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
We lacked of timestamp in tainting of guests log,
which bring troubles for finding guest issues:
such as whether a guest powerdown caused by qemu-monitor-command
or others issues inside guests.
If we had timestamp in tainting of guests log,
it would be helpful when checking guest's /var/log/messages.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
v2:
update logic flow of virDomainObjTaint check
src/qemu/qemu_domain.c | 79 +++++++++++++++++++++++++++-----------------------
1 file changed, 42 insertions(+), 37 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c676042..2bc023c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3999,46 +3999,51 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
{
virErrorPtr orig_err = NULL;
bool closeLog = false;
+ char *timestamp = NULL;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
- if (virDomainObjTaint(obj, taint)) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(obj->def->uuid, uuidstr);
-
- VIR_WARN("Domain id=%d name='%s' uuid=%s is tainted: %s",
- obj->def->id,
- obj->def->name,
- uuidstr,
- virDomainTaintTypeToString(taint));
-
- /* We don't care about errors logging taint info, so
- * preserve original error, and clear any error that
- * is raised */
- orig_err = virSaveLastError();
- if (logCtxt == NULL) {
- logCtxt = qemuDomainLogContextNew(driver, obj,
- QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH);
- if (!logCtxt) {
- if (orig_err) {
- virSetError(orig_err);
- virFreeError(orig_err);
- }
- VIR_WARN("Unable to open domainlog");
- return;
- }
- closeLog = true;
- }
+ if (!virDomainObjTaint(obj, taint))
+ return;
+
+ virUUIDFormat(obj->def->uuid, uuidstr);
+
+ VIR_WARN("Domain id=%d name='%s' uuid=%s is tainted: %s",
+ obj->def->id,
+ obj->def->name,
+ uuidstr,
+ virDomainTaintTypeToString(taint));
- if (qemuDomainLogContextWrite(logCtxt,
- "Domain id=%d is tainted: %s\n",
- obj->def->id,
- virDomainTaintTypeToString(taint)) < 0)
- virResetLastError();
- if (closeLog)
- qemuDomainLogContextFree(logCtxt);
- if (orig_err) {
- virSetError(orig_err);
- virFreeError(orig_err);
+ if ((timestamp = virTimeStringNow()) == NULL)
+ goto cleanup;
+
+ /* We don't care about errors logging taint info, so
+ * preserve original error, and clear any error that
+ * is raised */
+ orig_err = virSaveLastError();
+ if (logCtxt == NULL) {
+ logCtxt = qemuDomainLogContextNew(driver, obj,
+ QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH);
+ if (!logCtxt) {
+ VIR_WARN("Unable to open domainlog");
+ goto cleanup;
}
+ closeLog = true;
+ }
+
+ if (qemuDomainLogContextWrite(logCtxt,
+ "%s: Domain id=%d is tainted: %s\n",
+ timestamp,
+ obj->def->id,
+ virDomainTaintTypeToString(taint)) < 0)
+ virResetLastError();
+
+ cleanup:
+ VIR_FREE(timestamp);
+ if (closeLog)
+ qemuDomainLogContextFree(logCtxt);
+ if (orig_err) {
+ virSetError(orig_err);
+ virFreeError(orig_err);
}
}
--
2.7.4
7 years, 11 months
[libvirt] [PATCH 0/9] i386: query-cpu-model-expansion test script
by Eduardo Habkost
This is a follow-up to the series that implements
query-cpu-model-expansion. Before including the test script, the
series has some fixes to allow the results of
query-cpu-model-expansion to be used in the QEMU command-line.
The script probably will work on s390x too, but I couldn't test
it yet.
This series and its dependencies can be pulled from the branch:
https://github.com/ehabkost/qemu-hacks.git work/x86-query-cpu-expansion-test
---
Cc: Cornelia Huck <cornelia.huck(a)de.ibm.com>
Cc: Christian Borntraeger <borntraeger(a)de.ibm.com>
Cc: David Hildenbrand <david(a)redhat.com>
Cc: libvir-list(a)redhat.com
Cc: Jiri Denemark <jdenemar(a)redhat.com>
Cc: "Jason J. Herne" <jjherne(a)linux.vnet.ibm.com>
Cc: Markus Armbruster <armbru(a)redhat.com>
Cc: Richard Henderson <rth(a)twiddle.net>
Cc: Igor Mammedov <imammedo(a)redhat.com>
Cc: Eric Blake <eblake(a)redhat.com>
Eduardo Habkost (9):
target-i386: Move "host" properties to base class
target-i386: Allow short strings to be used as vendor ID
cpu: Support comma escaping when parsing -cpu
qemu.py: Make logging optional
qtest.py: Support QTEST_LOG environment variable
qtest.py: make logging optional
qtest.py: Make 'binary' parameter optional
tests: Add rules to non-gtester qtest test cases
tests: Test case for query-cpu-model-expansion
scripts/qemu.py | 25 ++-
scripts/qtest.py | 15 +-
qom/cpu.c | 32 ++--
target/i386/cpu.c | 83 ++++-----
tests/test-x86-cpuid-compat.c | 19 ++
tests/Makefile.include | 40 ++++-
tests/query-cpu-model-test.py | 398 ++++++++++++++++++++++++++++++++++++++++++
7 files changed, 551 insertions(+), 61 deletions(-)
create mode 100755 tests/query-cpu-model-test.py
--
2.11.0.259.g40922b1
7 years, 11 months
[libvirt] [PATCH python] Protect against user accidentally calling constructors directly
by Daniel P. Berrange
When using libvirt python you must never call the object
constructors directly, as these are expecting to be passed
a wrapped C object. For example
import libvirt
c = libvirt.virConnect("qemu:///system")
c.listAllDomains()
will mysteriously segfault. With this change the user now
gets an slightly more helpful error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/berrange/src/virt/libvirt-python/build/libvirt.py", line 3409, in __init__
raise Exception("Expected a wrapped C Object but got %s" % type(_obj))
Exception: Expected a wrapped C Object but got <type 'str'>
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/generator.py b/generator.py
index e9be8b1..6bcf80b 100755
--- a/generator.py
+++ b/generator.py
@@ -1532,6 +1532,8 @@ def buildWrappers(module):
elif classname in [ "virDomainSnapshot" ]:
classes.write(" self._dom = dom\n")
classes.write(" self._conn = dom.connect()\n")
+ classes.write(" if type(_obj).__name__ not in [\"PyCapsule\", \"PyCObject\"]:\n")
+ classes.write(" raise Exception(\"Expected a wrapped C Object but got %s\" % type(_obj))\n")
classes.write(" self._o = _obj\n\n")
destruct=None
if classname in classes_destructors:
--
2.9.3
7 years, 11 months
[libvirt] [PATCH] virDomainHostdevSubsysSCSIVHostDefParseXML: Don't leak @wwpn
by Michal Privoznik
==24748== 12 bytes in 2 blocks are definitely lost in loss record 25 of 84
==24748== at 0x4C2BF80: malloc (vg_replace_malloc.c:296)
==24748== by 0x1A1E1E78: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==24748== by 0x18D0495F: virXMLPropString (virxml.c:506)
==24748== by 0x18D1FB3E: virDomainHostdevSubsysSCSIVHostDefParseXML (domain_conf.c:6280)
==24748== by 0x18D20350: virDomainHostdevDefParseXMLSubsys (domain_conf.c:6450)
==24748== by 0x18D34E7D: virDomainHostdevDefParseXML (domain_conf.c:13218)
==24748== by 0x18D42598: virDomainDefParseXML (domain_conf.c:17745)
==24748== by 0x18D440A9: virDomainDefParseNode (domain_conf.c:18236)
==24748== by 0x18D43EFA: virDomainDefParse (domain_conf.c:18180)
==24748== by 0x18D43FA0: virDomainDefParseFile (domain_conf.c:18206)
==24748== by 0x44EDA1: testCompareDomXML2XMLFiles (testutils.c:1140)
==24748== by 0x4365F8: testXML2XMLActive (qemuxml2xmltest.c:59)
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 52aee2b02..55d2c25b2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6274,13 +6274,14 @@ static int
virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode,
virDomainHostdevDefPtr def)
{
- char *protocol = NULL;
+ char *protocol = NULL, *wwpn = NULL;
virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
+ int ret = -1;
if (!(protocol = virXMLPropString(sourcenode, "protocol"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing scsi_host subsystem protocol"));
- return -1;
+ return ret;
}
if ((hostsrc->protocol =
@@ -6293,17 +6294,19 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode,
switch ((virDomainHostdevSubsysSCSIHostProtocolType) hostsrc->protocol) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST:
- if (!(hostsrc->wwpn = virXMLPropString(sourcenode, "wwpn"))) {
+ if (!(wwpn = virXMLPropString(sourcenode, "wwpn"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing vhost-scsi hostdev source wwpn"));
goto cleanup;
}
- if (!STRPREFIX(hostsrc->wwpn, "naa.") ||
- !virValidateWWN(hostsrc->wwpn + 4)) {
+ if (!STRPREFIX(wwpn, "naa.") ||
+ !virValidateWWN(wwpn + 4)) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed 'wwpn' value"));
goto cleanup;
}
+ hostsrc->wwpn = wwpn;
+ wwpn = NULL;
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE:
case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST:
@@ -6314,12 +6317,11 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode,
break;
}
- return 0;
-
+ ret = 0;
cleanup:
- VIR_FREE(hostsrc->wwpn);
+ VIR_FREE(wwpn);
VIR_FREE(protocol);
- return -1;
+ return ret;
}
--
2.11.0
7 years, 11 months