[libvirt] [PATCH v2] qemu: add a max_core setting to qemu.conf for core dump size
by Daniel P. Berrange
Currently the QEMU processes inherit their core dump rlimit
from libvirtd, which is really suboptimal. This change allows
their limit to be directly controller from qemu.conf instead.
---
Changed in v2:
- Allow use of string "unlimited"
src/libvirt_private.syms | 2 ++
src/qemu/libvirtd_qemu.aug | 1 +
src/qemu/qemu.conf | 16 +++++++++++++++-
src/qemu/qemu_conf.c | 17 +++++++++++++++++
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_process.c | 1 +
src/qemu/test_libvirtd_qemu.aug.in | 1 +
src/util/vircommand.c | 14 ++++++++++++++
src/util/vircommand.h | 1 +
src/util/virprocess.c | 36 ++++++++++++++++++++++++++++++++++++
src/util/virprocess.h | 1 +
11 files changed, 90 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 597ce5f..773d935 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1371,6 +1371,7 @@ virCommandSetErrorFD;
virCommandSetGID;
virCommandSetInputBuffer;
virCommandSetInputFD;
+virCommandSetMaxCoreSize;
virCommandSetMaxFiles;
virCommandSetMaxMemLock;
virCommandSetMaxProcesses;
@@ -2180,6 +2181,7 @@ virProcessRunInMountNamespace;
virProcessSchedPolicyTypeFromString;
virProcessSchedPolicyTypeToString;
virProcessSetAffinity;
+virProcessSetMaxCoreSize;
virProcessSetMaxFiles;
virProcessSetMaxMemLock;
virProcessSetMaxProcesses;
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 8bc23ba..a8edc2b 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -72,6 +72,7 @@ module Libvirtd_qemu =
| bool_entry "set_process_name"
| int_entry "max_processes"
| int_entry "max_files"
+ | int_entry "max_core"
| str_entry "stdio_handler"
let device_entry = bool_entry "mac_filter"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 7964273..fac33ec 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -401,7 +401,21 @@
#max_processes = 0
#max_files = 0
-
+# If max_core is set to a positive integer, then QEMU will be
+# permitted to create core dumps when it crashes, provided its
+# RAM size is smaller than the limit set. Be warned that the
+# core dump will include a full copy of the guest RAM, so if
+# the largest guest is 32 GB in size, the max_core limit will
+# have to be at least 33/34 GB to allow enough overhead.
+#
+# As a special case it can be set to the string "unlimited" to
+# to allow arbitrarily sized core dumps.
+#
+# By default the core dump size is set to 0 disabling all dumps
+#
+# Size is in bytes or string "unlimited"
+#max_core = 0
+#max_core = "unlimited"
# mac_filter enables MAC addressed based filtering on bridge ports.
# This currently requires ebtables to be installed.
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fa9d65e..45d039c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -393,6 +393,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
char **controllers = NULL;
char **hugetlbfs = NULL;
char **nvram = NULL;
+ char *corestr = NULL;
/* Just check the file is readable before opening it, otherwise
* libvirt emits an error.
@@ -633,6 +634,21 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
if (virConfGetValueUInt(conf, "max_files", &cfg->maxFiles) < 0)
goto cleanup;
+ if (virConfGetValueType(conf, "max_core") == VIR_CONF_STRING) {
+ if (virConfGetValueString(conf, "max_core", &corestr) < 0)
+ goto cleanup;
+ if (STREQ(corestr, "unlimited")) {
+ cfg->maxCore = ULLONG_MAX;
+ } else {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unknown core size '%s'"),
+ corestr);
+ goto cleanup;
+ }
+ } else if (virConfGetValueULLong(conf, "max_core", &cfg->maxCore) < 0) {
+ goto cleanup;
+ }
+
if (virConfGetValueString(conf, "lock_manager", &cfg->lockManagerName) < 0)
goto cleanup;
if (virConfGetValueString(conf, "stdio_handler", &stdioHandler) < 0)
@@ -715,6 +731,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
virStringFreeList(controllers);
virStringFreeList(hugetlbfs);
virStringFreeList(nvram);
+ VIR_FREE(corestr);
VIR_FREE(user);
VIR_FREE(group);
virConfFree(conf);
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 510cd9a..b730202 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -148,6 +148,7 @@ struct _virQEMUDriverConfig {
unsigned int maxProcesses;
unsigned int maxFiles;
+ unsigned long long maxCore;
unsigned int maxQueuedJobs;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4adb14e..a7cbd59 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5069,6 +5069,7 @@ qemuProcessLaunch(virConnectPtr conn,
virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData);
virCommandSetMaxProcesses(cmd, cfg->maxProcesses);
virCommandSetMaxFiles(cmd, cfg->maxFiles);
+ virCommandSetMaxCoreSize(cmd, cfg->maxCore);
virCommandSetUmask(cmd, 0x002);
VIR_DEBUG("Setting up security labelling");
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index c4d4f19..c3d6da5 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -62,6 +62,7 @@ module Test_libvirtd_qemu =
{ "set_process_name" = "1" }
{ "max_processes" = "0" }
{ "max_files" = "0" }
+{ "max_core" = "0" }
{ "mac_filter" = "1" }
{ "relaxed_acs_check" = "1" }
{ "allow_disk_format_probing" = "1" }
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index f5bd7af..6baa37a 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -124,6 +124,8 @@ struct _virCommand {
unsigned long long maxMemLock;
unsigned int maxProcesses;
unsigned int maxFiles;
+ bool setMaxCore;
+ unsigned long long maxCore;
uid_t uid;
gid_t gid;
@@ -687,6 +689,9 @@ virExec(virCommandPtr cmd)
goto fork_error;
if (virProcessSetMaxFiles(0, cmd->maxFiles) < 0)
goto fork_error;
+ if (cmd->setMaxCore &&
+ virProcessSetMaxCoreSize(0, cmd->maxCore) < 0)
+ goto fork_error;
if (cmd->hook) {
VIR_DEBUG("Run hook %p %p", cmd->hook, cmd->opaque);
@@ -1105,6 +1110,15 @@ virCommandSetMaxFiles(virCommandPtr cmd, unsigned int files)
cmd->maxFiles = files;
}
+void virCommandSetMaxCoreSize(virCommandPtr cmd, unsigned long long bytes)
+{
+ if (!cmd || cmd->has_error)
+ return;
+
+ cmd->maxCore = bytes;
+ cmd->setMaxCore = true;
+}
+
void virCommandSetUmask(virCommandPtr cmd, int mask)
{
if (!cmd || cmd->has_error)
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index 44818ef..99dcdeb 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -75,6 +75,7 @@ void virCommandSetUID(virCommandPtr cmd, uid_t uid);
void virCommandSetMaxMemLock(virCommandPtr cmd, unsigned long long bytes);
void virCommandSetMaxProcesses(virCommandPtr cmd, unsigned int procs);
void virCommandSetMaxFiles(virCommandPtr cmd, unsigned int files);
+void virCommandSetMaxCoreSize(virCommandPtr cmd, unsigned long long bytes);
void virCommandSetUmask(virCommandPtr cmd, int umask);
void virCommandClearCaps(virCommandPtr cmd);
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 09dd3c9..2b71445 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -914,6 +914,42 @@ virProcessSetMaxFiles(pid_t pid ATTRIBUTE_UNUSED, unsigned int files)
}
#endif /* ! (HAVE_SETRLIMIT && defined(RLIMIT_NOFILE)) */
+#if HAVE_SETRLIMIT && defined(RLIMIT_CORE)
+int
+virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes)
+{
+ struct rlimit rlim;
+
+ rlim.rlim_cur = rlim.rlim_max = bytes;
+ if (pid == 0) {
+ if (setrlimit(RLIMIT_CORE, &rlim) < 0) {
+ virReportSystemError(errno,
+ _("cannot limit core file size to %llu"),
+ bytes);
+ return -1;
+ }
+ } else {
+ if (virProcessPrLimit(pid, RLIMIT_CORE, &rlim, NULL) < 0) {
+ virReportSystemError(errno,
+ _("cannot limit core file size "
+ "of process %lld to %llu"),
+ (long long int)pid, bytes);
+ return -1;
+ }
+ }
+ return 0;
+}
+#else /* ! (HAVE_SETRLIMIT && defined(RLIMIT_CORE)) */
+int
+virProcessSetMaxCoreSize(pid_t pid ATTRIBUTE_UNUSED,
+ unsigned long long bytes ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
+ return -1;
+}
+#endif /* ! (HAVE_SETRLIMIT && defined(RLIMIT_CORE)) */
+
+
#ifdef __linux__
/*
* Port of code from polkitunixprocess.c under terms
diff --git a/src/util/virprocess.h b/src/util/virprocess.h
index a7a1fe9..04e9802 100644
--- a/src/util/virprocess.h
+++ b/src/util/virprocess.h
@@ -75,6 +75,7 @@ int virProcessSetNamespaces(size_t nfdlist,
int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes);
int virProcessSetMaxProcesses(pid_t pid, unsigned int procs);
int virProcessSetMaxFiles(pid_t pid, unsigned int files);
+int virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes);
int virProcessGetMaxMemLock(pid_t pid, unsigned long long *bytes);
--
2.7.4
8 years, 10 months
[libvirt] [PATCH v2] storage: dir: adapts .wipeVol for ploop volumes
by Olga Krishtal
The modification of .volWipe callback wipes ploop volume using one of
given wiping algorithm: dod, nnsa, etc.
However, in case of ploop volume we need to reinitialize root.hds and DiskDescriptor.xml.
v2:
- added check on ploop tools presens
- virCommandAddArgFormat changed to virCommandAddArg
Signed-off-by: Olga Krishtal <okrishtal(a)virtuozzo.com>
---
src/storage/storage_backend.c | 68 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 62 insertions(+), 6 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 5adf1fd..14b3a64 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2195,6 +2195,55 @@ virStorageBackendWipeLocal(virStorageVolDefPtr vol,
return ret;
}
+static int
+virStorageBackendVolWipePloop(virStorageVolDefPtr vol)
+{
+ virCommandPtr cmd = NULL;
+ char *target_path = NULL;
+ char *disk_desc = NULL;
+ char *create_tool = NULL;
+
+ int ret = -1;
+
+ create_tool = virFindFileInPath("ploop");
+ if (!create_tool) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("unable to find ploop tools, please install them"));
+ return -1;
+ }
+
+ if (virAsprintf(&target_path, "%s/root.hds", vol->target.path) < 0)
+ goto cleanup;
+
+ if (virAsprintf(&disk_desc, "%s/DiskDescriptor.xml", vol->target.path) < 0)
+ goto cleanup;
+
+ if (virFileRemove(disk_desc, 0, 0) < 0) {
+ virReportError(errno, _("Failed to delete DiskDescriptor.xml of volume '%s'"),
+ vol->target.path);
+ goto cleanup;
+ }
+ if (virFileRemove(target_path, 0, 0) < 0) {
+ virReportError(errno, _("failed to delete root.hds of volume '%s'"),
+ vol->target.path);
+ goto cleanup;
+ }
+
+ cmd = virCommandNewArgList(create_tool, "init", "-s", NULL);
+
+ virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
+ (1024 * 1024)));
+ virCommandAddArgList(cmd, "-t", "ext4", NULL);
+ virCommandAddArg(cmd, target_path);
+ ret = virCommandRun(cmd, NULL);
+
+ cleanup:
+ VIR_FREE(disk_desc);
+ VIR_FREE(target_path);
+ VIR_FREE(create_tool);
+ virCommandFree(cmd);
+ return ret;
+}
int
virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -2207,6 +2256,8 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
const char *alg_char = NULL;
struct stat st;
virCommandPtr cmd = NULL;
+ char *path = NULL;
+ char *target_path = vol->target.path;
virCheckFlags(0, -1);
@@ -2214,12 +2265,12 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
vol->target.path, algorithm);
if (vol->target.format == VIR_STORAGE_FILE_PLOOP) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("wiping for ploop volumes is not supported"));
- goto cleanup;
+ if (virAsprintf(&path, "%s/root.hds", vol->target.path) < 0)
+ goto cleanup;
+ target_path = path;
}
- fd = open(vol->target.path, O_RDWR);
+ fd = open(target_path, O_RDWR);
if (fd == -1) {
virReportSystemError(errno,
_("Failed to open storage volume with path '%s'"),
@@ -2276,13 +2327,12 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
if (algorithm != VIR_STORAGE_VOL_WIPE_ALG_ZERO) {
cmd = virCommandNew(SCRUB);
virCommandAddArgList(cmd, "-f", "-p", alg_char,
- vol->target.path, NULL);
+ target_path, NULL);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
ret = 0;
- goto cleanup;
} else {
if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
ret = virStorageBackendVolZeroSparseFileLocal(vol, st.st_size, fd);
@@ -2292,10 +2342,16 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
vol->target.allocation,
st.st_blksize);
}
+ if (ret < 0)
+ goto cleanup;
}
+ if (vol->target.format == VIR_STORAGE_FILE_PLOOP)
+ ret = virStorageBackendVolWipePloop(vol);
+
cleanup:
virCommandFree(cmd);
+ VIR_FREE(path);
VIR_FORCE_CLOSE(fd);
return ret;
}
--
1.8.3.1
8 years, 10 months
[libvirt] [PATCH] tests: add missed directories in EXTRA_DIST
by Luyao Huang
In commit ec5dcf2a and b0b4a35c, we have moved some xml to
new directories, but forget fix the Makefile. Add 2 directories
in EXTRA_DIST to fix broken vpath build.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
tests/Makefile.am | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fb2380d..010e348 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -122,6 +122,8 @@ EXTRA_DIST = \
qemucaps2xmldata \
qemuhelpdata \
qemuhotplugtestdata \
+ qemuhotplugtestdevices \
+ qemuhotplugtestdomains \
qemumonitorjsondata \
qemuxml2argvdata \
qemuxml2xmloutdata \
--
1.8.3.1
8 years, 10 months
[libvirt] [PATCH v2] virCommandExec: Report error if execve fails
by Michal Privoznik
In an unlikely event of execve() failing, the virCommandExec()
function does not report any error, even though checks that are
at the beginning of the function are verbose when failing.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
diff to v1:
- Fixed the test (used virFork() instead of plain fork(),
prolonged the waiting time for child reply, ...)
src/util/vircommand.c | 7 +++++-
tests/commandtest.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index f5bd7af..3c67c90 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2152,7 +2152,12 @@ int virCommandExec(virCommandPtr cmd)
return -1;
}
- return execve(cmd->args[0], cmd->args, cmd->env);
+ execve(cmd->args[0], cmd->args, cmd->env);
+
+ virReportSystemError(errno,
+ _("cannot execute binary %s"),
+ cmd->args[0]);
+ return -1;
}
#else
int virCommandExec(virCommandPtr cmd ATTRIBUTE_UNUSED)
diff --git a/tests/commandtest.c b/tests/commandtest.c
index f433ad7..2b77b9b 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -1063,6 +1063,74 @@ static int test24(const void *unused ATTRIBUTE_UNUSED)
return ret;
}
+
+static int test25(const void *unused ATTRIBUTE_UNUSED)
+{
+ int ret = -1;
+ int pipeFD[2] = { -1, -1};
+ char rv = 0;
+ ssize_t tries = 100;
+ pid_t pid;
+
+ if (pipe(pipeFD) < 0) {
+ fprintf(stderr, "Unable to create pipe\n");
+ goto cleanup;
+ }
+
+ if (virSetNonBlock(pipeFD[0]) < 0) {
+ fprintf(stderr, "Unable to make read end of pipe nonblocking\n");
+ goto cleanup;
+ }
+
+ /* Now, fork and try to exec a nonexistent binary. */
+ pid = virFork();
+ if (pid < 0) {
+ fprintf(stderr, "Unable to spawn child\n");
+ goto cleanup;
+ }
+
+ if (pid == 0) {
+ /* Child */
+ virCommandPtr cmd = virCommandNew("some/nonexistent/binary");
+
+ rv = virCommandExec(cmd);
+ if (safewrite(pipeFD[1], &rv, sizeof(rv)) < 0)
+ fprintf(stderr, "Unable to write to pipe\n");
+ _exit(EXIT_FAILURE);
+ }
+
+ /* Parent */
+ while (--tries) {
+ if (saferead(pipeFD[0], &rv, sizeof(rv)) < 0) {
+ if (errno != EWOULDBLOCK) {
+ fprintf(stderr, "Unable to read from pipe\n");
+ goto cleanup;
+ }
+
+ usleep(10 * 1000);
+ } else {
+ break;
+ }
+ }
+
+ if (!tries) {
+ fprintf(stderr, "Child hasn't returned anything\n");
+ goto cleanup;
+ }
+
+ if (rv >= 0) {
+ fprintf(stderr, "Child should have returned an error\n");
+ goto cleanup;
+ }
+
+ ret = 0;
+ cleanup:
+ VIR_FORCE_CLOSE(pipeFD[0]);
+ VIR_FORCE_CLOSE(pipeFD[1]);
+ return ret;
+}
+
+
static void virCommandThreadWorker(void *opaque)
{
virCommandTestDataPtr test = opaque;
@@ -1215,6 +1283,7 @@ mymain(void)
DO_TEST(test22);
DO_TEST(test23);
DO_TEST(test24);
+ DO_TEST(test25);
virMutexLock(&test->lock);
if (test->running) {
--
2.8.4
8 years, 10 months
[libvirt] [PATCH 0/2] Add qemu hotplug tests with ccw devices
by Tomasz Flendrich
These changes require another patch, or else there would be conflicts:
[libvirt] [PATCH 0/3] Clean up qemuhotplugtest xml files
https://www.redhat.com/archives/libvir-list/2016-July/msg00202.html
Hotplugging ccw devices was previously not tested, so I decided
to add some testcases because I plan on making changes to different
address types and want to make sure regression won't happen.
Please let me know if you think that the filenames are too long.
I know that some device files are duplicated. It is (right now) required
because of the way qemuhotplugtest.c calculates the expected xml
filenames. I plan on changing that to explicitly stating the basis
xml, the device xml, and the expected xml, so that there would
be no duplicates. It will also make filenames shorter.
In another patch, I will add testcases that verify attaching a device
to the persistent config. Explicitly stating the expected xml
will be even more useful then.
Tomasz Flendrich (2):
Add qemu hotplug test files
Add ccw test cases to qemu hotplug
tests/qemuhotplugtest.c | 37 +++++++++++
.../qemuhotplug-ccw-virtio-1-explicit-reverse.xml | 8 +++
.../qemuhotplug-ccw-virtio-1-explicit.xml | 8 +++
.../qemuhotplug-ccw-virtio-2-explicit.xml | 8 +++
.../qemuhotplug-ccw-virtio-2.xml | 8 +++
.../qemuhotplug-ccw-virtio.xml | 8 +++
.../qemuhotplug-base-ccw-live+ccw-virtio.xml | 63 +++++++++++++++++++
...-2-ccw-virtio+ccw-virtio-1-explicit-reverse.xml | 73 ++++++++++++++++++++++
...ive-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 73 ++++++++++++++++++++++
...qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml | 63 +++++++++++++++++++
...-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 73 ++++++++++++++++++++++
...-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml | 73 ++++++++++++++++++++++
.../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 63 +++++++++++++++++++
.../qemuhotplug-base-ccw-live.xml | 53 ++++++++++++++++
14 files changed, 611 insertions(+)
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit-reverse.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-1-explicit.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2-explicit.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio-2.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-ccw-virtio.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit-reverse.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml
--
1.9.1
8 years, 10 months
[libvirt] question about PCI new_id sysfs interface
by Jim Fehlig
After updating the dom0 kernel on one of my Xen test hosts, I noticed problems
with PCI hostdev management. E.g
# virsh nodedev-detach pci_0000_07_10_1
error: Failed to detach device pci_0000_07_10_1
error: Failed to add PCI device ID '8086 1520' to pciback: File exists
It turns out there was a small interface change to new_id with the following
commit to 3.16 kernel
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/dr...
which now causes xen_pciback to fail writes of "vendorid productid" to new_id. e.g.
# echo "8086 1520" > /sys/bus/pci/drivers/pciback/new_id
-bash: echo: write error: File exists
Interestingly, vfio doesn't encounter the same error
# echo "8086 1520" > /sys/bus/pci/drivers/vfio-pci/new_id
# echo $?
0
vfio-pci has:
static struct pci_driver vfio_pci_driver = {
.name = "vfio-pci",
.id_table = NULL, /* only dynamic ids */
while xen-pciback has:
static const struct pci_device_id pcistub_ids[] = {
{
.vendor = PCI_ANY_ID,
.device = PCI_ANY_ID,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
},
{0,},
};
static struct pci_driver xen_pcibk_pci_driver = {
.name = "pciback",
.id_table = pcistub_ids,
So any vendor/device pair will match for xen-pciback, while none will match for
vfio-pci.
But after reading that commit and the associated thread, it is not clear to me
how to best fix this. Options are
1. set .id_table to NULL for xen-pciback
2. drop using the new_id interface from libvirt
3. pass more values (subvendor, subdevice, class, etc) to the new_id interface
I'm not sure what problems, if any, options 1 and 2 might cause. Option 2 seems
the best approach since new_id seems to be a rather unsafe interface.
Thanks for your opinions!
Regards,
Jim
8 years, 10 months
[libvirt] [PATCH] virCommandExec: Report error if execve fails
by Michal Privoznik
In an unlikely event of execve() failing, the virCommandExec()
function does not report any error, even though checks that are
at the beginning of the function are verbose when failing.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/vircommand.c | 7 +++++-
tests/commandtest.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index f5bd7af..3c67c90 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2152,7 +2152,12 @@ int virCommandExec(virCommandPtr cmd)
return -1;
}
- return execve(cmd->args[0], cmd->args, cmd->env);
+ execve(cmd->args[0], cmd->args, cmd->env);
+
+ virReportSystemError(errno,
+ _("cannot execute binary %s"),
+ cmd->args[0]);
+ return -1;
}
#else
int virCommandExec(virCommandPtr cmd ATTRIBUTE_UNUSED)
diff --git a/tests/commandtest.c b/tests/commandtest.c
index f433ad7..8dc57d7 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -1063,6 +1063,74 @@ static int test24(const void *unused ATTRIBUTE_UNUSED)
return ret;
}
+
+static int test25(const void *unused ATTRIBUTE_UNUSED)
+{
+ int ret = -1;
+ int pipeFD[2] = { -1, -1};
+ int rv = 0;
+ ssize_t tries = 10;
+ pid_t pid;
+
+ if (pipe(pipeFD) < 0) {
+ fprintf(stderr, "Unable to create pipe\n");
+ goto cleanup;
+ }
+
+ if (virSetNonBlock(pipeFD[0]) < 0) {
+ fprintf(stderr, "Unable to make read end of pipe nonblocking\n");
+ goto cleanup;
+ }
+
+ /* Now, fork and try to exec a nonexistent binary. */
+ pid = fork();
+ if (pid < 0) {
+ fprintf(stderr, "Unable to spawn child\n");
+ goto cleanup;
+ }
+
+ if (pid == 0) {
+ /* Child */
+ virCommandPtr cmd = virCommandNew("some/nonexistent/binary");
+
+ rv = virCommandExec(cmd);
+ if (safewrite(pipeFD[1], (void *) &rv, sizeof(rv)) < 0)
+ fprintf(stderr, "Unable to write to pipe\n");
+ _exit(EXIT_FAILURE);
+ }
+
+ /* Parent */
+ while (tries--) {
+ if (saferead(pipeFD[0], (void *) &rv, sizeof(rv)) < 0) {
+ if (errno != EWOULDBLOCK) {
+ fprintf(stderr, "Unable to read from pipe\n");
+ goto cleanup;
+ }
+
+ usleep(1000);
+ } else {
+ break;
+ }
+ }
+
+ if (!tries) {
+ fprintf(stderr, "Child hasn't returned anything\n");
+ goto cleanup;
+ }
+
+ if (rv >= 0) {
+ fprintf(stderr, "Child should have returned an error\n");
+ goto cleanup;
+ }
+
+ ret = 0;
+ cleanup:
+ VIR_FORCE_CLOSE(pipeFD[0]);
+ VIR_FORCE_CLOSE(pipeFD[1]);
+ return ret;
+}
+
+
static void virCommandThreadWorker(void *opaque)
{
virCommandTestDataPtr test = opaque;
@@ -1215,6 +1283,7 @@ mymain(void)
DO_TEST(test22);
DO_TEST(test23);
DO_TEST(test24);
+ DO_TEST(test25);
virMutexLock(&test->lock);
if (test->running) {
--
2.8.4
8 years, 10 months
[libvirt] [PATCHv2 0/3] qemu: add support for intel-iommu
by Ján Tomko
https://bugzilla.redhat.com/show_bug.cgi?id=1235581
v2:
* removed '-iommu' suffix from the model name
* mentioned the device in formatdomain.html
* added the device to ABI stability check
and the hot/coldplug parser (where both operations
are rejected)
* error out on non-q35 machines
* added a comment about broken qemu to the commit message
of patch 2/3
* no change wrt the device order on the command line -
qemu seems to take care of this
Ján Tomko (3):
Introduce <iommu> device
Add QEMU_CAPS_DEVICE_INTEL_IOMMU
qemu: format intel-iommu on the command line
docs/formatdomain.html.in | 26 +++++++
docs/schemas/domaincommon.rng | 11 +++
src/conf/domain_conf.c | 90 +++++++++++++++++++++-
src/conf/domain_conf.h | 16 ++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 35 +++++++++
src/qemu/qemu_driver.c | 6 ++
src/qemu/qemu_hotplug.c | 1 +
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-intel-iommu.args | 22 ++++++
.../qemuxml2argvdata/qemuxml2argv-intel-iommu.xml | 37 +++++++++
tests/qemuxml2argvtest.c | 2 +
.../qemuxml2xmlout-intel-iommu.xml | 37 +++++++++
tests/qemuxml2xmltest.c | 4 +
18 files changed, 294 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu.xml
--
2.7.3
8 years, 10 months